package com.zy.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import javax.servlet.http.HttpServletRequest;

public class MailInfo extends Properties{
	private static MailInfo mailInfo;
	/*根据类路径读取
	public  MailInfo(){
		InputStream is = this.getClass().getResourceAsStream("mail.properties");
		try {
			load(is);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	public  static   MailInfo  getInstance(){
		if(mailInfo==null){
			makeMailInfo();
			return mailInfo;
		}else{
			return  mailInfo;
		}
	}
	public   static  void makeMailInfo(){
		if(mailInfo==null){
			 mailInfo= new MailInfo();
		}
	}*/
	//根据路径去读取
	public  MailInfo(HttpServletRequest request){
		InputStream is = request.getSession().getServletContext().getResourceAsStream("WEB-INF/classes/mail.properties");
		try {
			load(is);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	public  static   MailInfo  getInstance(HttpServletRequest request){
		if(mailInfo==null){
			makeMailInfo(request);
			return mailInfo;
		}else{
			return  mailInfo;
		}
	}
	public   static  void makeMailInfo(HttpServletRequest request){
		if(mailInfo==null){
			 mailInfo= new MailInfo(request);
		}
	}
}
